using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using THSLib;
using THSERP.BusinessEntities;
namespace THSERP.BaseProvider
{
    public partial class guiObjectHistoryDetails : THSERPScreen
    {
        public guiObjectHistoryDetails()
        {
            InitializeComponent();
        }
        public guiObjectHistoryDetails(int iIndexRowHandle,String iObjectNumber)
        {
            InitializeComponent();
            InitialzeGridControl(iIndexRowHandle,iObjectNumber);
        }
        private void InitialzeGridControl(int iIndexRowHandle,String iObjectNumber)
        {
            try
            {
                GEObjectHistoryController objGEObjectHistoryController = new GEObjectHistoryController();
                DataSet dsObjectHistory = objGEObjectHistoryController.GetGEObjectHistoryByObjectNumber(iObjectNumber.ToString());
                
                String strPrimaryKey = THSDbUtil.GetTablePrimaryColumn(THSUtil.GetTableNameFromBusinessObjectType(typeof(GEObjectHistoryInfo)));
                int iHistoryObjectID = int.Parse(dsObjectHistory.Tables[0].Rows[iIndexRowHandle][strPrimaryKey].ToString());
                BingdingObjectHistoryDetailGridControl(iHistoryObjectID);
            }
            catch (Exception ex)
            {

            }
        }
        private void BingdingObjectHistoryDetailGridControl(int iHistoryObjectID)
        {
            GEObjectHistoryDetailController objGEObjectHistoryDetailsController = new GEObjectHistoryDetailController();
            DataSet dsObjectHistoryDetails = objGEObjectHistoryDetailsController.GEObjectHistoryDetailsByHistoryID(iHistoryObjectID);
            if (dsObjectHistoryDetails != null)
            {
                if (dsObjectHistoryDetails.Tables.Count > 0)
                {
                    fld_dgcObjectHistoryDetails.DataSource = dsObjectHistoryDetails;
                    fld_dgcObjectHistoryDetails.DataMember = dsObjectHistoryDetails.Tables[0].TableName;
                }
            }
        }

        private void fld_btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}